<?php

class GDGE_Bootstrap
{
	
	public function __construct($gdge_path, $zend_path=null)
	{
		$this->_setupPath($gdge_path, $zend_path);
		$this->_setupAutoload();
	}
	
	private function _setupPath($gdge_path, $zend_path)
	{
		$newPath = '.' . PATH_SEPARATOR . $gdge_path;
		if ($zend_path != null)
			$newPath .= PATH_SEPARATOR . $zend_path;
		$newPath .= PATH_SEPARATOR . get_include_path();
		set_include_path($newPath);
	}
	
	private function _setupAutoload()
	{
		require_once 'Zend/Loader/Autoloader.php';
		$autoloader = Zend_Loader_Autoloader::getInstance();
		$autoloader->registerNamespace('GDGE_');
	}
	
	public function initSession($sessionName) {
		Zend_Session::start(array('name' => $sessionName));
	}
	
	public function initDatabase($adapter, $config) {
		$db = Zend_Db::factory($adapter, $config);
		Zend_Db_Table_Abstract::setDefaultAdapter($db);
		Zend_Registry::set('db', $db);
		return $db;
	}
	
}